home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions Axon component
-
- #include "NSDLL.h"
-
- /***********************************/
- /* Forward activation of component */
-
- __declspec(dllexport) void performFuzzyAxon(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *param, // Pointer to the layer of parameters for the MFs
- int paramIndex, // Index into the param array
- int PEIndex, // Index into the processing elements of the Axon
- // (the data array)
- NSFloat *returnVal // Value to return after applying the MF
- )
- {
- int baseIndex = paramIndex * 2;
- NSFloat c = *(param + baseIndex);
- NSFloat sigma = *(param + baseIndex + 1);
- if (sigma == 0.0f)
- *returnVal = 0.0f;
- else {
- NSFloat exp_fraction = (*(data + PEIndex) - c) / sigma;
- NSFloat exp_final = (NSFloat) (((double)exp_fraction*(double)exp_fraction) / (double)-2.0);
- *returnVal = (NSFloat)exp(exp_final);
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
-
- __declspec(dllexport) DLLData *allocFuzzyAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- int *paramCount // Number of parameters per MF
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- *paramCount = 2;
- return instance;
- }
-
- __declspec(dllexport) void freeFuzzyAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-